<?php
/**
 * 小程序我的钱包
 */
namespace app\mini\controller;
class Wallet extends Pre
{
    public function lists(){
        $loginInfo = $this -> loginInfo;
        $data = $this -> data;
        //加入已读缓存
        $cacheNum = cache('mini_num');
        $cacheNum['wallet'] = \app\common\model\Wallet::where('account_id',$loginInfo['id'])->column('id');
        cache('mini_num',$cacheNum,3600*24*365);

        //待提现
        $info = \app\common\model\Wallet::with('message')->where([
            'account_id' => $loginInfo['id'],
        ])->select()->toArray();

        foreach ($info as $k=>$value){
            $value['date'] = date('Y-m-d H:i:s',$value['date']);
            if ($value['status'] =='0'){
                $wait[] = $value;
            }
            else{
                $complete[] = $value;
            }
        }

        $findPoint[] = ['building_id','eq',$loginInfo['project']];
        $findPoint[] = $loginInfo['role'] =='33'?['action','eq','4']:['role','eq',$loginInfo['role']];

        $point = \app\common\model\BuildingPoint::where($findPoint)->find();

        return [
            'content' => $data['mark']==1?$complete:$wait,
            'num' => count($wait),
            'numed' => count($complete),
            'point' => explode(',',$point['point'])
        ];
    }


}